#pragma once
#include <iostream>
#include <string>
#include <functional>
#include <pthread.h>

using func_t = std::function<void()>;
class Thread
{
    static void *ThreadRoute(void *args)
    {
        Thread* self = static_cast<Thread*>(args);
        self->_func();
        return nullptr;
    }
public:
    Thread(const std::string& name, func_t func)
        : _name(name), _func(func)
    {
    }
    void Start()
    {
        pthread_create(&_tid, nullptr, ThreadRoute, this);
    }
    void Join()
    {
        pthread_join(_tid, nullptr);
    }

    ~Thread() {}

private:
    std::string _name;
    func_t _func;
    pthread_t _tid;
};